package com.distribute.sso.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.distribute.common.pojo.DistributeResult;
import com.distribute.sso.service.AdministratorService;

@Controller
@RequestMapping("/administrator")
public class AdministratorController {

	@Autowired
	AdministratorService administratorService;

	@RequestMapping(value = "/login", method = RequestMethod.POST)
	@ResponseBody
	public DistributeResult administratorLogin(String account, String password, HttpServletRequest request,
			HttpServletResponse response) {
		try {
			DistributeResult result = administratorService.login(account.trim(), password.trim(), request, response);
			return result;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return DistributeResult.build(500, "内部错误");
		}

	}

}
